import type { Plugin, App } from "vue";
import AppPage from "@/components/app-layout/AppPage.vue";
import TriggerAutoImport from "@/components/misc/TriggerAutoImport.vue";
import { formInstall } from "@/components/form";
import { tableInstall } from "@/components/table";
import { listPageInstall } from "@/components/list-page";
import { modalInstall } from "@/components/modal";

const components = {
  AppPage,
  TriggerAutoImport,
};

export const globalComponent: Plugin = {
  install(app: App) {
    Object.entries<Parameters<typeof app.component>[1]>(components).forEach(
      ([name, component]) => {
        app.component(name, component);
      },
    );
    app.use(formInstall);
    app.use(tableInstall);
    app.use(listPageInstall);
    app.use(modalInstall);
  },
};
